package org.hk.proxy.common.constant;

/**
 * @author ：PengQiuju
 * @date ：Created in 2019/12/19
 * @description ：返回信息状态枚举
 */
public enum ApiStateEnum {
    ERROR(500, "错误"),
    SUCCESS(200, "成功"),
    MESSAGE(333, "信息提示"),
    TOKEN_INVALID(401,"身份令牌token无效"),
    METHOD_ALLOW(405,"请求方式错误"),
    /**
     * 大屏
     */
    NO_LOGIN_IN(10001, "未登录"),
    PARM_ERROR(10002, "参数错误"),
    FORBIND(10005, "禁止请求"),
    ACCOUNT_PWD_ERROR(10003, "账号或密码错误"),
    DP_SCREENCODE_ERROR(10004, "大屏视图代码错误");

    ApiStateEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static ApiStateEnum getApiStateEnumByCode(Integer code) {
        ApiStateEnum[] apiStateEnums = ApiStateEnum.values();
        for (ApiStateEnum apiStateEnum : apiStateEnums) {
            if (code.equals(apiStateEnum.getCode())) {
                return apiStateEnum;
            }
        }
        return null;
    }

    private Integer code;
    private String name;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
